﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RiskMan.DataClass.Models;
using RiskMan.Views.Dialogs;

namespace RiskMan.Config
{
    /// <summary>
    /// Логика взаимодействия для ComisView.xaml
    /// </summary>
    public partial class ComisView : Window
    {
        public MMVBComisClass Item;

        public ComisView ( )
        {
            InitializeComponent( );

            Item = new MMVBComisClass( );

            textBox1.Text = "0.5";
            textBox2.Text = "0";
            textBox3.Text = "20 000";
        }

        private void button2_Click ( object sender, RoutedEventArgs e )
        {
            Item = null;
            Close( );
        }

        private void button1_Click ( object sender, RoutedEventArgs e )
        {
            try
            {
                Item.Comis = cfg.ToDoubleFormControls( textBox1.Text );
                Item.FromComis = cfg.ToDoubleFormControls( textBox2.Text );
                Item.ToComis = cfg.ToDoubleFormControls( textBox3.Text );
                Close( );
            }
            catch ( Exception ex )
            {
                new DialogMessage( "Поля заполнены некорректно! \r\nОшибка: " + ex.Message, "Ошибка" );
            }
        }
    }
}